#!/bin/bash

CreateGameField ()
{
  for((i=0;i<100;i++))
  do
    field[i]=" + "
  done
}

PrintField ()
{
  echo "     0  1  2  3  4  5  6  7  8  9  "
  echo "   -------------------------------- "
  for ((i=0;i<10;i++))
  do
    echo -n " $i |"
    for ((j=0;j<10;j++))
    do
      if [[ ${field[$i*10 + $j]} == "   " ]]
      then
        echo -ne "\e[1;31m${field[$i*10 + $j]}\e[0m"
      else
        echo -n "${field[$i*10 + $j]}"
      fi
    done
    echo "|"
  done
    echo "   -------------------------------- "
}

#Ïåðåìåííûå
LENGTH_OF_ONE_ARG=4
CreateGameField;
for arg in $@
do
  if [[ ${#arg} -eq "$LENGTH_OF_ONE_ARG" ]] && [[ "$arg" =~ ^[0-9]{4}$ ]]
  then
    row_start=${arg:0:1}
    row_end=${arg:2:1}
    column_start=${arg:1:1}
    column_end=${arg:3:1}
    if [[ "$row_start" -ne "$row_end" && "$column_start" -ne "$column_end" ]]
    then
      echo "Wrong Argument"
    else
      for((i=$row_start;i <= $row_end;i++))
      do
      	for((j=$column_start;j <= $column_end;j++))
        do
				  field[10*i+j]="   "; 
			 done				
		  done
    fi
  else
    echo "Wrong Argument"
  fi
done
PrintField;
exit 0;
